<?= kvframework_markup::form_remote_tag(array("update" => 'box', "url" => self::url_for('appointment', 'create_form_process'), 302 => "hideBox(true);", "loading" => 'doLoading2(true);', "complete" => "doLoading2(false);")) ?>
<table border="0" cellspacing="0">
  <tbody>
    <tr>
      <td class="leftward">
        <div class="title"><h1><?= ($this->reschedule) ? "Rescheduling" : "New" ?> Meeting</h1><div class="cancelbutton"><a href="#" onclick="hideBox(false);">cancel</a></div></div>
        <div id="insetbox">
            <input type="hidden" name="step" id="step" />
          <input type="hidden" name="max_step" id="max_step" value="<?= $this->max_step ?>" />

          <input type="hidden" name="date" id="date" value="<?= TOOLS::date_to_s($this->date) ?>" />
          <input type="hidden" name="starttime" id="starttime" value="<?= TOOLS::time_to_s($this->start) ?>" />
          <input type="hidden" name="stoptime" id="stoptime" value="<?= TOOLS::time_to_s($this->stop) ?>" />
          <input type="hidden" name="consultant" id="consultant" value="<?= $this->thisguy->id ?>" />

          <input type="hidden" name="fi[appttype_id]" id="fi[appttype_id]" value="<?= $this->appttype_id ?>" />
          <input type="hidden" name="fi[repeat]" id="fi[repeat]" value="<?= $this->repeat ?>" />
          <input type="hidden" name="fi[multi_user]" id="fi[multi_user]" value="<?= $this->multi_user ?>" />
          <input type="hidden" name="fi[special2]" id="fi[special2]" value="<?= $this->special2 ?>" />

          <input type="hidden" name="fi[enddate]" id="fi[enddate]" value="<?= ($this->enddate) ? TOOLS::date_to_s($this->enddate) : "" ?>" />
          <input type="hidden" name="fi[repetition_week]" id="fi[repetition_week]" value="<?= $this->rep_week ?>" />
          <input type="hidden" name="repetition_day" id="repetition_day" value="<?= implode(",",$this->rep_day) ?>" />

          <input type="hidden" name="other_consultants" id="other_consultants" value="<?= implode(",",$this->other_rcs) ?>" />

          <?php if($this->reschedule) { ?>
            <input type="hidden" name="reschedule" id="reschedule" value="<?= $this->reschedule ?>" />
          <?php } ?>

	  <?php foreach($this->concur_override as $loctag => $answ)
          { ?>
                    <input type="hidden" name="concur_override[<?=$loctag?>]" id="concur_override_<?=$loctag?>" value="<?= $answ ?>" />
          <?php } ?>
          <input type="hidden" name="length_override" id="length_override" value="<?= $this->length_override ?>" />
          <input type="hidden" name="time_conf" id="time_conf" value="<?= $this->time_override ?>" />
          <input type="hidden" name="finals_conf" id="finals_conf" value="<?= $this->finals_override ?>" />
          <input type="hidden" name="dist_conf" id="dist_conf" value="<?= $this->far_override ?>" />
          <input type="hidden" name="appthour_override" id="appthour_override" value="<?= $this->appthour_override ?>" />
          <input type="hidden" name="gen_conf" id="gen_conf" value="<?= $this->gender_override ?>" />

          <div id="leftpane">
          Date and Time: <?= TOOLS::date_to_s($this->date) ?> from <?= TOOLS::time_to_s($this->start, true) ?> to <?= TOOLS::mytime_select(array("display12h" => true, "selected" => $this->stop, "name" => 'stoptime', "on_minutes" => 30, "min_hour" => (int)TOOLS::hour_s_for($this->start), "max_hour" => (int)TOOLS::hour_s_for($this->stopmax))) ?> (max: <?= TOOLS::time_to_s($this->stopmax, true) ?><input type="hidden" name="fi[stopmax]" id="fi[stopmax]" value="<?= TOOLS::time_to_s($this->stopmax) ?>" />)<br />
          Type: <?= ($this->special2 == "meeting") ? "Meeting" : (($this->special2 == "meecket") ? "Special Appointment" : "Regular Appointment") ?> for <?= Appttype::select_name($this->appttype) ?><br />
          <?php if ($this->repeat == "TRUE") { ?>
          Repetition: Every <?= ($this->rep_week == 1) ? "week" : $this->rep_week." weeks" ?> on <?= implode(", ", TOOLS::array_collect($this->rep_day, '$i', 'TOOLS::$daynames[TOOLS::weekday_reverse($i)]')) ?> until <?= TOOLS::date_to_s($this->enddate) ?><br />
          <?php } ?>

          <?php if ($this->multi_user == "TRUE") { ?>
            Consultants: <?= Consultant::select_name($this->thisguy) ?>, <?= implode(", ", $this->rc_names) ?><br />
          <?php } else { ?>
            Consultant: <?= Consultant::select_name($this->thisguy) ?><br />
          <?php } ?>
            <br />

            <?php if (count(explode(",",$this->appttype->tm_class)) > 1 &&  !$this->thing) { ?>
              <div class="line">Meeting Type</div>
              <div class="line2"><?= kvframework_markup::select(array("name" => "fi[special2]", "values" => TOOLS::array_collect(explode(",", $this->appttype->tm_class), '$t', 'array(($t == "Meecket") ? "Other" : $t, strtolower($t))'), "selected" => $this->special2, "class" => 'txtbox2')) ?> <a href="#" onclick="fill_in_unavailable(new Array('fi[locdetails]', 'fi[subject]','fi[details]'))">unavailable</a></div>
             <?php } elseif ($this->thing) { ?>
               <div class="line">Meeting Type</div>
              <div class="line2"><?= ucwords($this->special2) ?>
              <input type="hidden" name="fi[special2]" id="fi[special2]" value="<?= $this->special2 ?>" /></div>
            <?php } else { ?>
              <input type="hidden" name="fi[special2]" id="fi[special2]" value="<?= $this->special2 ?>" />
            <?php } ?>

            <div class="line">Meeting Location</div>
            <div class="line2"><?= kvframework_markup::select(array("name" => "fi[loc_id]", "values" => $this->all_locs, "prompt" => true, "selected" => ($this->loc_id) ? $this->loc_id : (($this->appttype and $this->appttype->default_loc != 0) ? $this->appttype->default_loc : null), "class" => 'txtbox2')) ?></div>

            <div class="line">Location Details (Room etc.)</div>
            <div class="line2"><input type="text" name="fi[locdetails]" id="fi[locdetails]" value="<?= ($this->locdetails) ? $this->locdetails : (($this->appttype) ? $this->appttype->default_locdetails : null) ?>" class="txtbox" /></div>

            <div class="line">Meeting Subject</div>
            <div class="line2"><input type="text" name="fi[subject]" id="fi[subject]" class="txtbox" value="<?= ($this->thing && !$this->subject) ? $this->thing->subject : $this->subject ?>" /></div>

            <div class="line">Description</div>
            <div class="line2"><textarea class="txtbox3" cols="60" rows="10" name="fi[details]" id="fi[details]"><?= preg_replace("#<br />#","\n", ($this->thing && !$this->details) ? $this->thing->description : $this->details) ?></textarea></div>

            <?php if($this->thing) { ?>
              <input type="hidden" name="tid" id="tid" value="<?= $this->thing->id ?>" />
              <input type="hidden" name="ttype" id="ttype" value="<?= $this->thing->tm_type ?>" />
            <?php } ?>
          </div>
        </div>
        <div class="button"><input type="submit" value="back" onclick="document.getElementById('step').value = 'prev';" class="btn" /><input type="submit" value="next" class="btn" /></div>
      </td>
      <td class="spacer"></td>
      <td class="rightward">
        <?= $this->outputMessages() ?>
        <?= $this->outputErrors() ?>
      </td>
    </tr>
  </tbody>
</table>
<input type="hidden" name="thisstep" id="thisstep" value="thing" />
</form>
